﻿<DataListSpec 
	xmlns="bb_appfx_datalist"
	xmlns:common="bb_appfx_commontypes" 
	ID="d48497d5-df17-44e1-b73b-c3f4a0bdd8a9" 
	Name="Service Bus Adapter Log Data List"
	Description="List service bus adapter log entries." 
	Author="Blackbaud Professional Services"
	common:SecurityUIFolder="Service Bus Adapter"
  >

	<!-- define the SP that returns the data for the datalist -->
	<SPDataList SPName="USR_USP_DATALIST_SERVICEBUSADAPTER">
		<common:CreateProcedureSQL>
			<![CDATA[
create procedure dbo.USR_USP_DATALIST_SERVICEBUSADAPTER(
  @DATEFROM datetime = null,
  @DATETO datetime = null,
  @ENTRYTYPECODE int = null,
  @DETAILS nvarchar(100) = null
)
as
	set nocount on;

	select 
    SERVERNAME,
    LOGDATE,
    case ENTRYTYPECODE
      when 1 then 'Error'
      when 2 then 'Warning'
      when 4 then 'Information'
    end as ENTRYTYPE,
    DETAILS
    --,CORRELATIONID
	from 
    dbo.USR_SERVICEBUSADAPTERLOG
	where 
    (LOGDATE >= @DATEFROM or @DATEFROM is null)
		and (LOGDATE <= @DATETO or @DATETO is null)
    and (ENTRYTYPECODE = @ENTRYTYPECODE or @ENTRYTYPECODE is null)
    and (DETAILS like '%' + @DETAILS + '%' or @DETAILS is null)
  order by
    LOGDATE desc,
    ENTRYTYPECODE,
    SERVERNAME
    
    ]]>
		</common:CreateProcedureSQL>
	</SPDataList>

	<!-- describe any parameters (other than the context ID) defined on the SP -->
	<Parameters>
		<common:FormMetaData>
			<common:FormFields>
				<common:FormField FieldID="DATEFROM" Caption="Date from" DataType="Date" IncludeTimeOnDate="true" />
        <common:FormField FieldID="DATETO" Caption="Date to" DataType="Date" IncludeTimeOnDate="true" />
        <common:FormField FieldID="ENTRYTYPECODE" Caption="Entry type" DataType="Integer">
          <common:ValueList>
            <common:Items>
              <common:Item>
                <common:Value>1</common:Value>
                <common:Label>Error</common:Label>
              </common:Item>
              <common:Item>
                <common:Value>2</common:Value>
                <common:Label>Warning</common:Label>
              </common:Item>
              <common:Item>
                <common:Value>4</common:Value>
                <common:Label>Information</common:Label>
              </common:Item>
            </common:Items>
          </common:ValueList>
        </common:FormField>
        <common:FormField FieldID="DETAILS" Caption="Details" DataType="String" MaxLength="100" />
			</common:FormFields>
		</common:FormMetaData>
	</Parameters>

	<!-- define the output fields in the list -->
	<Output>
		<OutputFields>
			<OutputField FieldID="SERVERNAME" Caption="Server" DataType="String" />
			<OutputField FieldID="LOGDATE" Caption="Date" DataType="Date" DisplayDateAsDateTime="true" />
			<OutputField FieldID="ENTRYTYPE" Caption="Entry type" DataType="String" />
      <OutputField FieldID="DETAILS" Caption="Details" DataType="String" />
      <!--<OutputField FieldID="CORRELATIONID" Caption="Correlation ID" DataType="Guid" />-->
		</OutputFields>
	</Output>

</DataListSpec>
